package com.gaga.metadata.model;

import com.gaga.metadata.entity.base.BaseTable;
import freemarker.template.Configuration;
import freemarker.template.Template;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * @Description //TODO
 * @Date 2023/4/24 15:58
 * @Author zhipeng.yang
 **/
public abstract class AbstractModelProvider<T extends BaseTable> {

    public Logger logger = LoggerFactory.getLogger(this.getClass());

    public abstract String handler(T table);

    /**
     * 构建freemarker template
     *
     * @return
     * @throws IOException
     */
    protected Template buildFreemarkerTemplate(String templateName) throws IOException {
        Template template = null;
        Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
        configuration.setClassForTemplateLoading(AbstractModelProvider.class, "/templates/");
        configuration.setDefaultEncoding("utf-8");
        template = configuration.getTemplate(templateName);
        return template;
    }


}
